home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / streambu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  18.9 KB  |  852 lines

  1. #ifndef __STD_STREAMBUF__
  2. #define __STD_STREAMBUF__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * streambuf - Declarations for the Standard Library stream buffers
  8.  *
  9.  * $Id: streambuf,v 1.52 1996/09/24 19:18:25 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  14.  * ALL RIGHTS RESERVED *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  * 
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #include <stdcomp.h>
  46.  
  47. #ifndef _RWSTD_NO_NEW_HEADER
  48. #include <cstdlib>
  49. #else
  50. #include <stdlib.h>
  51. #endif
  52.  
  53. #include <ios>
  54.  
  55. #ifndef _RWSTD_NO_NAMESPACE
  56. namespace std {
  57. #endif
  58.  
  59. template<class charT, class traits>
  60. class _RWSTDExportTemplate basic_streambuf {
  61.  
  62.   public:
  63.      
  64.     typedef charT                        char_type;
  65.     typedef traits                                traits_type;
  66.     typedef _TYPENAME traits::int_type              int_type;
  67.     typedef _TYPENAME traits::pos_type              pos_type;
  68.     typedef _TYPENAME traits::off_type              off_type;
  69.  
  70.  
  71. virtual ~basic_streambuf();
  72.  
  73. locale pubimbue( const locale& loc);
  74. locale getloc() const; 
  75.  
  76.  
  77. inline  basic_streambuf<char_type, traits> *
  78.          pubsetbuf(char_type *s, streamsize n);
  79.  
  80. inline pos_type pubseekoff(off_type off, ios_base::seekdir way,
  81.                            ios_base::openmode which =
  82.                    ios_base::in | ios_base::out);
  83.  
  84. inline pos_type pubseekpos(pos_type sp, ios_base::openmode which =
  85.                            ios_base::in | ios_base::out);
  86.  
  87. inline int pubsync( );
  88.  
  89. inline ios_base::openmode which_open_mode();
  90.  
  91. inline streamsize   in_avail();
  92.  
  93. inline int_type snextc();
  94.  
  95. inline int_type sbumpc();
  96.  
  97. inline int_type sgetc();
  98.  
  99. inline streamsize sgetn(char_type *s, streamsize n);
  100.  
  101. inline int_type sputbackc(char_type c);
  102.  
  103. inline int_type sungetc();
  104.  
  105. inline int_type sputc(char_type c);
  106.  
  107. inline streamsize sputn(const char_type *s, streamsize n);
  108.  
  109. #ifdef _RWSTD_MULTI_THREAD
  110.   _RWSTDMutex buffer_mutex_;
  111.  
  112.   void _RW_lock_buffer()
  113.   {
  114.     _RWSTDGuard* tmp = new _RWSTDGuard(buffer_mutex_);
  115.     if ( tmp )
  116.      buffer_guard = tmp;
  117.     else
  118.      buffer_guard = 0;
  119.   }
  120.  
  121.   void _RW_unlock_buffer()
  122.   {
  123.     if ( buffer_guard )
  124.      {
  125.        delete buffer_guard;
  126.        buffer_guard = 0;
  127.      }
  128.   }
  129.  
  130. #endif
  131.  
  132. protected:
  133.  
  134.     basic_streambuf();
  135.  
  136.     ios_base::openmode mode_;
  137.      
  138.     inline char_type *eback() const;    
  139.     inline char_type *gptr() const;
  140.     inline char_type *egptr() const;
  141.  
  142.     inline void gbump(int n);
  143.  
  144.     inline void setg(char_type *gbeg_arg,char_type *gnext_arg,char_type *gend_arg);
  145.  
  146.  
  147.     inline char_type *pbase() const;    
  148.     inline char_type *pptr() const;    
  149.     inline char_type *epptr() const;
  150.  
  151.     inline void pbump(int n);
  152.  
  153.     inline void setp(char_type *pbeg_arg,char_type *pend_arg);
  154.  
  155.    virtual void imbue( const locale& loc);
  156.     
  157.    virtual int_type overflow(int_type c = traits::eof());
  158.  
  159.    virtual int_type pbackfail(int_type c = traits::eof());
  160.  
  161.    virtual int showmanyc();
  162.  
  163.    virtual int_type underflow();
  164.  
  165.    virtual int_type uflow();
  166.  
  167.    virtual streamsize xsgetn(char_type *s, streamsize n);
  168.  
  169.    virtual streamsize xsputn(const char_type *s, streamsize n);
  170.  
  171.    virtual pos_type seekoff(off_type off,
  172.                             ios_base::seekdir way, ios_base::openmode which = 
  173.                             ios_base::in | ios_base::out);
  174.  
  175.     virtual pos_type seekpos(pos_type sp,
  176.                              ios_base::openmode which = 
  177.                              ios_base::in | ios_base::out);
  178.  
  179.     virtual basic_streambuf<charT, traits> *
  180.       setbuf(char_type *s, streamsize n);
  181.  
  182.  
  183.     virtual int sync( );
  184.  
  185.     void streambuf_init(bool set_mode= true);
  186.  
  187.   private:
  188.  
  189.     char_type       *gbeg_;    
  190.     char_type       *gnext_;  
  191.     char_type       *gend_;    
  192.  
  193.     char_type       *pbeg_;   
  194.     char_type       *pnext_;   
  195.     char_type       *pend_;  
  196.  
  197.     locale             loc_buf; 
  198.  
  199.     #ifdef _RWSTD_MULTI_THREAD
  200.      _RWSTDGuard *buffer_guard; 
  201.     #endif     
  202. };
  203.  
  204.  
  205. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  206. // inline functions
  207. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  208.  
  209. /*
  210.  * int_type snextc()
  211.  *
  212.  * returns the next character
  213.  */
  214.  
  215. template<class charT, class traits>
  216. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  217. basic_streambuf<charT, traits>::snextc()
  218. {
  219.   if( traits::eq_int_type(sbumpc(),traits::eof()) )
  220.     return traits::eof();
  221.  
  222.   return sgetc();
  223. }
  224.  
  225. /*
  226.  * int_type sbumpc()
  227.  *
  228.  * returns the current character and increments the pointer
  229.  */
  230.  
  231. template<class charT, class traits>
  232. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  233. basic_streambuf<charT, traits>::sbumpc()
  234.   char_type c;
  235.  
  236.   if( gptr()>= egptr()) {
  237.     return uflow();
  238.   } 
  239.  
  240.   c=*gptr();  
  241.   gbump(1); 
  242.   return traits::to_int_type(c);
  243. }
  244.  
  245. /*
  246.  * int_type sgetc()
  247.  *
  248.  * returns the current character
  249.  */
  250.  
  251. template<class charT, class traits>
  252. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  253. basic_streambuf<charT, traits>::sgetc()
  254. {
  255.  
  256.   if(gptr() >= egptr()) {  
  257.     return underflow();
  258.   }
  259.  
  260.   return traits::to_int_type(*gptr());
  261. }
  262.  
  263. /*
  264.  * streamsize sgetn(char_type *, streamsize)
  265.  *
  266.  * reads in 'n' characters into 's'
  267.  */
  268.  
  269. template<class charT, class traits>
  270. inline streamsize basic_streambuf<charT, traits>::
  271. sgetn(char_type *s, streamsize n)
  272. {
  273.   return xsgetn(s, n);
  274. }
  275.  
  276.  
  277. /*
  278.  * int_type sputbackc(char_type)
  279.  *
  280.  * puts the character back into the sequence if possible
  281.  */
  282.  
  283. template<class charT, class traits>
  284. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  285. basic_streambuf<charT, traits>::sputbackc(char_type c)
  286. {
  287.   if( gptr() > eback()) { 
  288.     gbump(-1);
  289.     if( !traits::eq(*gptr(),c) ) { 
  290.       gbump(1); 
  291.       return pbackfail(traits::to_int_type(c));
  292.     }
  293.  
  294.     return traits::to_int_type(*gptr());
  295.   }
  296.  
  297.   return pbackfail(traits::to_int_type(c)); 
  298. }
  299.  
  300.  
  301. /*
  302.  * int sungetc()
  303.  *
  304.  * puts the character back into the sequence. The putback character doesn't
  305.  * have to already be there.  Similar to sputbackc(...)
  306.  */
  307.  
  308. template<class charT, class traits>
  309. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  310. basic_streambuf<charT, traits>::sungetc()
  311. {
  312.   if(gptr() > eback())
  313.      {
  314.         gbump(-1);
  315.         return traits::to_int_type(*gptr());
  316.      } 
  317.  
  318.   return pbackfail();
  319. }
  320.  
  321. /*
  322.  * int sputc(char_type)
  323.  *
  324.  * puts the character into the sequence
  325.  */
  326.  
  327. template<class charT, class traits>
  328. inline _TYPENAME basic_streambuf<charT, traits>::int_type
  329. basic_streambuf<charT, traits>::sputc(char_type c)
  330. {
  331.   
  332.   if( pptr() >= epptr() ) {
  333.     return overflow(traits::to_int_type(c));
  334.   }
  335.  
  336.  *pnext_++ =c; 
  337.  return traits::to_int_type(c);
  338. }
  339.  
  340. /*
  341.  * streamsize sputn(const char_type *, streamsize)
  342.  *
  343.  * writes n characters from s into the sequence
  344.  */
  345.  
  346. template<class charT, class traits>
  347. inline streamsize
  348. basic_streambuf<charT, traits>::sputn(const char_type *s, streamsize n)
  349. {
  350.   return xsputn(s, n);
  351. }
  352.  
  353. /*
  354.  * void gbump(int)
  355.  *
  356.  * increments the get pointer by n.  Does no checking to see if this
  357.  * is a valid operation
  358.  */
  359.  
  360. template<class charT, class traits>
  361. inline void 
  362. basic_streambuf<charT, traits>::gbump(int n)
  363. {
  364.   gnext_ += n;
  365. }
  366.  
  367. /*
  368.  * void setg(char_type *, char_type *, char_type *)
  369.  * 
  370.  * sets the get pointers
  371.  */
  372.  
  373. template<class charT, class traits>
  374. inline void 
  375. basic_streambuf<charT, traits>::
  376. setg(char_type *gbeg, char_type *gnext, char_type *gend)
  377. {
  378.   gbeg_ = gbeg;
  379.   gnext_ = gnext;
  380.   gend_ = gend;
  381. }
  382.  
  383.  
  384. /*
  385.  * void pbump(int)
  386.  *
  387.  * increments the put pointer.  No checking to see if this is valid
  388.  */
  389.  
  390. template<class charT, class traits>
  391. inline void 
  392. basic_streambuf<charT, traits>::pbump(int n)
  393. {
  394.   pnext_ += n;
  395. }
  396.  
  397. /*
  398.  * void setp(char_type *, char_type *)
  399.  *
  400.  * sets up the put pointers
  401.  */
  402.  
  403. template<class charT, class traits>
  404. inline void 
  405. basic_streambuf<charT, traits>::
  406. setp(char_type *pbeg, char_type *pend)
  407. {
  408.   pbeg_ = pbeg;
  409.   pnext_ = pbeg;
  410.   pend_ = pend;
  411. }
  412.  
  413. /*
  414.  * char_type *eback() const
  415.  *
  416.  * returns the beginning of the get sequence
  417.  */
  418.  
  419. template<class charT, class traits>
  420. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  421. basic_streambuf<charT, traits>::eback() const
  422. {
  423.   return gbeg_;
  424. }
  425.  
  426. /*
  427.  * char_type *gptr() const
  428.  */
  429.  
  430. template<class charT, class traits>
  431. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  432. basic_streambuf<charT, traits>::gptr() const
  433. {
  434.   return gnext_;
  435. }
  436.  
  437. /*
  438.  * char_type *egptr() const
  439.  */
  440.  
  441. template<class charT, class traits>
  442. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  443. basic_streambuf<charT, traits>::egptr() const
  444. {
  445.   return gend_;
  446. }
  447.  
  448. /*
  449.  * char_type *pbase() const
  450.  */
  451.  
  452. template<class charT, class traits>
  453. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  454. basic_streambuf<charT, traits>::pbase() const
  455. {
  456.   return pbeg_;
  457. }
  458.  
  459. /*
  460.  * char_type *pptr() const
  461.  */
  462.  
  463. template<class charT, class traits>
  464. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  465. basic_streambuf<charT, traits>::pptr() const
  466. {
  467.   return pnext_;
  468. }
  469.  
  470. /*
  471.  * char_type *epptr() const
  472.  */
  473.  
  474. template<class charT, class traits>
  475. inline _TYPENAME basic_streambuf<charT, traits>::char_type *
  476. basic_streambuf<charT, traits>::epptr() const
  477. {
  478.   return pend_;
  479. }
  480.  
  481.  
  482. /*
  483.  * streamsize in_avail()
  484.  *
  485.  * returns how many characters are available
  486.  */
  487.  
  488. template<class charT, class traits>
  489. inline streamsize 
  490. basic_streambuf<charT, traits>::in_avail()
  491. {
  492.   if(gptr() >= egptr())
  493.     return showmanyc();
  494.  
  495.   return ( (streamsize)(egptr() - gptr()) );
  496. }
  497.  
  498.  
  499. /*
  500.  * int pubsync()
  501.  */
  502.  
  503. template<class charT, class traits>
  504. inline int 
  505. basic_streambuf<charT, traits>::pubsync()
  506. {
  507.   return sync();
  508. }
  509.  
  510.  
  511. /*
  512.  * pos_type pubseekoff(off_type, ios_base::seekdir, ios_base::openmode)
  513.  */
  514.  
  515. template<class charT, class traits>
  516. inline _TYPENAME basic_streambuf<charT, traits>::pos_type
  517. basic_streambuf<charT, traits>::
  518. pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which)
  519. {
  520.   return seekoff(off, way, which);
  521. }
  522.  
  523. /*
  524.  * pos_type pubseekpos(pos_type, ios_base::openmode)
  525.  */
  526. template<class charT, class traits>
  527. inline _TYPENAME basic_streambuf<charT, traits>::pos_type
  528. basic_streambuf<charT, traits>::
  529. pubseekpos(pos_type sp,
  530.            ios_base::openmode which)
  531. {
  532.   return seekpos(sp, which);
  533. }
  534.  
  535. /*
  536.  * basic_streambuf *pubsetbuf(char_type *, streamsize)
  537.  */
  538.  
  539. template<class charT, class traits>
  540. inline  basic_streambuf<charT, traits> *
  541. basic_streambuf<charT, traits>::
  542. pubsetbuf(char_type *s, streamsize n)
  543. {
  544.   return setbuf(s, n);
  545. }
  546.  
  547. /*
  548.  * ios_base::openmode which_open_mode()
  549.  */
  550.  
  551. template<class charT, class traits>
  552. inline ios_base::openmode
  553. basic_streambuf<charT, traits>::which_open_mode()
  554. {
  555.   return mode_; 
  556. }
  557.  
  558.  
  559. // END OF INLINE FUNCTIONS
  560.  
  561. /*
  562.  *   streambuf iterators
  563.  */
  564.  
  565. //
  566. // ostreambuf_iterator
  567. //
  568.  
  569. template<class charT, class traits >
  570. class _RWSTDExportTemplate ostreambuf_iterator : public output_iterator {
  571.  
  572.   public:
  573.  
  574.     typedef charT                          char_type;
  575.     typedef traits                         traits_type;
  576.     typedef basic_streambuf<charT, traits> streambuf_type;
  577.     typedef basic_ostream<charT, traits>   ostream_type;
  578.  
  579.     ostreambuf_iterator(ostream_type& s) _RWSTD_INLINE_NO_THROW
  580.     : sbuf_(s.rdbuf())
  581.     {
  582.        if ( s.rdbuf() ) failed_flag = false;
  583.        else 
  584.         failed_flag = true; 
  585.     }
  586.  
  587.     ostreambuf_iterator(streambuf_type *s) _RWSTD_INLINE_NO_THROW
  588.     : sbuf_(s)
  589.     { 
  590.       if ( s ) failed_flag = false;
  591.       else 
  592.        failed_flag = true;
  593.     }
  594.  
  595.     ostreambuf_iterator<charT,traits>& operator*()
  596.     { return *this; }
  597.     ostreambuf_iterator<charT,traits>& operator++()
  598.     { return *this; }
  599.     ostreambuf_iterator<charT,traits> operator++(int)
  600.     { return *this; }
  601.  
  602.     ostreambuf_iterator<charT,traits>& operator=(charT c)
  603.       { 
  604.         if ( !failed_flag )
  605.         {
  606.           if ( traits::eq_int_type(sbuf_->sputc(c),traits::eof()) )
  607.            failed_flag=true;
  608.         }
  609.         return *this;
  610.       }
  611.  
  612.     bool failed( ) const _RWSTD_INLINE_NO_THROW
  613.     { return failed_flag; }
  614.      
  615.  
  616.   protected:
  617.  
  618.   private:
  619.  
  620.     streambuf_type        *sbuf_;
  621.     bool                  failed_flag;
  622.  
  623. };
  624.  
  625. //
  626. // istreambuf_iterator 
  627. //
  628.  
  629. template<class charT, class traits >
  630. class _RWSTDExportTemplate istreambuf_iterator : public input_iterator<charT>
  631. {
  632.  
  633.   public:
  634.  
  635.     typedef charT                          char_type;
  636.     typedef _TYPENAME traits::int_type      int_type;
  637.     typedef traits                         traits_type;
  638.     typedef basic_streambuf<charT, traits> streambuf_type;
  639.     typedef basic_istream<charT, traits>   istream_type;
  640.  
  641.     // class to maintain a character and an associated streambuf
  642.     class proxy {
  643.  
  644.         char_type                      keep_;
  645.         streambuf_type             *sbuf_;
  646.  
  647.         proxy(char_type c, streambuf_type *sbuf)
  648.           : keep_(c), sbuf_(sbuf)
  649.           { ; }
  650.  
  651.       public:
  652.  
  653.         char_type operator*()
  654.           { return keep_; }
  655.  
  656.         friend class istreambuf_iterator<charT, traits>;
  657.  
  658.     };
  659.  
  660.   public:
  661.  
  662.     istreambuf_iterator()  _RWSTD_INLINE_NO_THROW
  663.     : sbuf_(0)
  664.     { failed_flag = true; }
  665.     istreambuf_iterator(istream_type& s)  _RWSTD_INLINE_NO_THROW
  666.     : sbuf_(s.rdbuf())
  667.     { 
  668.       if ( s.rdbuf() ) failed_flag = false;
  669.       else 
  670.        failed_flag = true; 
  671.     }
  672.     istreambuf_iterator(streambuf_type *s) _RWSTD_INLINE_NO_THROW
  673.     : sbuf_(s)
  674.     {
  675.       if ( s ) failed_flag = false;
  676.       else 
  677.        failed_flag = true;
  678.     }
  679.     istreambuf_iterator(const proxy& p) _RWSTD_INLINE_NO_THROW
  680.     : sbuf_(p.sbuf_)
  681.     { ; }
  682.     inline char_type operator*();
  683.     inline istreambuf_iterator<charT, traits>& operator++();
  684.     inline proxy operator++(int);
  685.     inline bool equal(istreambuf_iterator<charT, traits>& b);
  686.  
  687.     bool failed( ) const _RWSTD_INLINE_NO_THROW
  688.     { return failed_flag; }
  689.  
  690.   protected:
  691.  
  692.   private:
  693.  
  694.     streambuf_type     *sbuf_;
  695.     bool               failed_flag;
  696.  
  697. };
  698.  
  699. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  700. // inline functions
  701. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  702.  
  703. /*
  704.  * char_type operator*()
  705.  */
  706.  
  707. template<class charT, class traits>
  708. inline _TYPENAME istreambuf_iterator<charT, traits>::char_type
  709. istreambuf_iterator<charT, traits>::operator*()
  710. {
  711.   int_type c;
  712.  
  713.   if ( sbuf_ && !failed_flag )
  714.    {
  715.      c= sbuf_->sgetc();
  716.      if ( traits::eq_int_type(c,traits::eof()) ) 
  717.       {
  718.         sbuf_ = 0;
  719.         failed_flag = true;
  720.       }
  721.    }
  722.   else return traits::eof();
  723.  
  724.   return traits::to_char_type(c);
  725.   
  726. }
  727.  
  728. /*
  729.  * istreambuf_iterator& operator++()
  730.  */
  731.  
  732. template<class charT, class traits>
  733. inline istreambuf_iterator<charT, traits>&
  734. istreambuf_iterator<charT, traits>::operator++()
  735. {
  736.   if (sbuf_ && !failed_flag )
  737.    { 
  738.      sbuf_->sbumpc();
  739.      if ( traits::eq_int_type(sbuf_->sgetc(),traits::eof()) ) 
  740.       {
  741.         sbuf_ = 0;
  742.         failed_flag = true;
  743.       } 
  744.    }
  745.  
  746.   return *this;
  747. }
  748.  
  749. /*
  750.  * proxy operator++(int)
  751.  */
  752.  
  753. template<class charT, class traits>
  754. inline _TYPENAME istreambuf_iterator<charT, traits>::proxy 
  755. istreambuf_iterator<charT, traits>::operator++(int)
  756. {
  757.  
  758.   if (sbuf_ && !failed_flag )
  759.     {
  760.       proxy     prev(sbuf_->sgetc(), sbuf_);
  761.       sbuf_->sbumpc();
  762.       if ( traits::eq_int_type(sbuf_->sgetc(),traits::eof()) ) 
  763.       {
  764.         sbuf_ = 0;
  765.         failed_flag = true;
  766.       }  
  767.       return prev;
  768.     }
  769.     
  770.    charT     c=traits::to_char_type(traits::eof());
  771.    return proxy(c, sbuf_);
  772.     
  773.  
  774. }
  775.  
  776. /*
  777.  * bool equal(istreambuf_iterator&)
  778.  */
  779.  
  780. template<class charT, class traits>
  781. inline bool
  782. istreambuf_iterator<charT, traits>::
  783. equal(istreambuf_iterator<charT, traits>& b)
  784. {
  785.   if( ((sbuf_ ==0) && (b.sbuf_==0)) || ((sbuf_ !=0) && (b.sbuf_ !=0)) )
  786.     return true;  
  787.   else
  788.     return false;
  789. }
  790.  
  791.  
  792. /*
  793.  * bool operator==(istreambuf_iterator& a, istreambuf_iterator& b)
  794.  */
  795.  
  796. template<class charT, class traits>
  797. inline bool _RWSTDExportTemplate operator==(istreambuf_iterator<charT, traits>& a,
  798.                 istreambuf_iterator<charT, traits>& b)
  799. {
  800.   return a.equal(b);
  801. }
  802.  
  803.  
  804. /*
  805.  * bool operator!=(istreambuf_iterator& a, istreambuf_iterator& b)
  806.  */
  807.  
  808. template<class charT, class traits>
  809. inline bool _RWSTDExportTemplate operator!=(istreambuf_iterator<charT, traits>& a,
  810.                 istreambuf_iterator<charT, traits>& b)
  811. {
  812.   return !(a.equal(b));
  813. }
  814.  
  815. // end inlining
  816.  
  817.  
  818.  
  819. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  820. typedef basic_streambuf<char>                            streambuf;
  821. #else
  822. typedef basic_streambuf<char, char_traits<char> >         streambuf;
  823. #endif
  824.  
  825. #ifndef _RWSTD_NO_WIDE_CHAR
  826. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  827. typedef basic_streambuf<wchar_t>                         wstreambuf;
  828. #else
  829. typedef basic_streambuf<wchar_t, char_traits<wchar_t> >   wstreambuf;
  830. #endif
  831. #endif
  832.  
  833.  
  834. #ifndef _RWSTD_NO_NAMESPACE
  835. }
  836. #endif
  837.  
  838.  
  839.  
  840. #ifdef _RWSTD_COMPILE_INSTANTIATE
  841. #include <streambu.cc>
  842. #endif
  843.  
  844. #ifndef __USE_STD_NAMES__
  845.   using namespace std;
  846. #endif
  847.  
  848. #pragma option pop
  849.  
  850. #endif /* __STREAMBUF__ */
  851.